{extend name="public/base"/}

{block name="body"}
	<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
	<div class="main-title">
		<h2>
			{$info['id']?'编辑':'新增'}广告
		</h2>
	</div>
	<form action="{:Url()}" method="post" class="form-horizontal">
		<div class="form-item">
			<label class="item-label">广告说明<span class="check-tips">合理的广告说明有利于SEO</span></label>
			<div class="controls">
				<input type="text" class="text input-large" name="title" value="{$info.title|default=''}">
			</div>
		</div>
		<div class="form-item">
			<label class="item-label">Url<span class="check-tips">http开头的链接</span></label>
			<div class="controls">
				<input type="text" class="text input-large" name="url" value="{$info.url|default=''}">
			</div>
		</div>
		<div class="form-item">
			<label class="item-label">打开位置<span class="check-tips">"_blank" 等</span></label>
			<div class="controls">
				<input type="text" class="text input-large" name="target" value="{$info.target|default=''}">
			</div>
		</div>
		<div class="form-item">
			<label class="item-label">广告图片<span class="check-tips">[宽：{$position['width']}，高：{$position['height']}]</span></label>

			<div class="controls">
				<input type="file" id="upload_picture_data">
				<input type="hidden" name="data" id="cover_id_data" value="{$info['data']}"/>
				<div class="upload-img-box">
					{notempty name="info['data']"}
					<div class="upload-pre-item"><img src="{$info['data']|get_cover='path'}"/></div>
					{/notempty}
				</div>
			</div>
			<script type="text/javascript">
//上传图片
/* 初始化上传插件 */
$("#upload_picture_data").uploadify({
	"height"          : 30,
	"swf"             : "__STATIC__/uploadify/uploadify.swf",
	"fileObjName"     : "data",
	"buttonText"      : "上传图片",
	"uploader"        : "{:Url('File/uploadPicture',array('session_id'=>session_id()))}",
	"width"           : 120,
	'removeTimeout'	  : 1,
	'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
	"onUploadSuccess" : uploadPicturedata,
	'onFallback' : function() {
		alert('未检测到兼容版本的Flash.');
	}
});
function uploadPicturedata(file, data){
	var data = $.parseJSON(data);
	var src = '';
	if(data.code && data.data.data){
		$("#cover_id_data").val(data.data.data.id);
		src = data.data.data.url || '__ROOT__' + data.data.data.path
			$("#cover_id_data").parent().find('.upload-img-box').html(
					'<div class="upload-pre-item"><img src="' + src + '"/></div>'
					);
	} else {
		updateAlert(data.msg);
		setTimeout(function(){
			$('#top-alert').find('button').click();
			$(that).removeClass('disabled').prop('disabled',false);
		},1500);
	}
}
			</script>
		</div>

		<div class="form-item">
			<label class="item-label">开始时间<span class="check-tips"></span></label>
			<div class="controls">
				<input type="text" class="text input-large time" name="start_time" value="{$info.start_time|default=''}" placeholder="请选择日期">
			</div>
		</div>
		<div class="form-item">
			<label class="item-label">结束时间<span class="check-tips"></span></label>
			<div class="controls">
				<input type="text" class="text input-large time" name="end_time" value="{$info.end_time|default=''}" placeholder="请选择日期">
			</div>
		</div>
		<div class="form-item">
			<input type="hidden" name="position" value="{$info.position|default=input('param.position')}">
			<input type="hidden" name="id" value="{$info.id|default=''}">
			<button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
			<button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
		</div>
	</form>
{/block}
{block name="script"}
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
{php}if(Config('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';{/php}
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript" charset="utf-8">
$(function(){
	//导航高亮
	highlight_subnav('{:Url('AdPosition/index')}');
	$('.date').datetimepicker({
		format: 'yyyy-mm-dd',
		language:"zh-CN",
		minView:2,
		autoclose:true
	});
	$('.time').datetimepicker({
		format: 'yyyy-mm-dd hh:ii',
		language:"zh-CN",
		minView:2,
		autoclose:true
	});
})
</script>
{/block}
